home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / JForth / Textra120 / Scripts / TestMarks.textra < prev    next >
Encoding:
Text File  |  1996-02-10  |  22.3 KB  |  902 lines

  1. /*
  2. **
  3. ** Textra MARKS-Facility Exerciser/Tester
  4. ** --------------------------------------
  5. ** Mike Haas - 11 January 1996
  6. **
  7. ** Textra 1.15 introduced the MARKs facility, a convienient
  8. ** method of setting persistant "bookmarks" with user-definable
  9. ** names to any section of a file.  Unfortunately, Textra 1.16
  10. ** and earlier have some problems dealing with the MARKs table
  11. ** correctly in all edit situations.  In those versions, it is
  12. ** possible for defined Marks to become invisible or change
  13. ** locations.
  14. **
  15. ** This is a test file for Textra's MARKs facility.  It opens
  16. ** 2 windows, one for logging results and the other to actually
  17. ** conduct its tests in.  The MARKs algorithms are extensively
  18. ** exercised and the results checked.  You may log all test
  19. ** results or only problems.  The latest Textra runs all tests
  20. ** with no problems.
  21. **
  22. ** The basic pattern of these tests is to establish various types
  23. ** of marks (single-line, two-line, multi-line) and place the
  24. ** cursor in various places (on a previous line, same line
  25. ** before, within, after, following line) then perform some
  26. ** operation (del a char, del a select range, etc.) and check
  27. ** that the mark was properly adjusted or deleted or left
  28. ** unchanged, depending on the operation.
  29. **
  30. ** This script will reveal the problems with Textra 1.16
  31. ** and earlier, all of which are fixed in Textra 1.17 (which
  32. ** is in beta, not generally available yet).  See what a good idea
  33. ** it is to register shareware programs?  You get the latest and
  34. ** greatest. In Textra's case, free updates and bonus software,
  35. ** too!
  36. **
  37. ** (For you conspiracy buffs: No, I didn't intentionally put
  38. ** the bugs in the earlier versions just so I could release this
  39. ** script as a trick to get people to upgrade :-)  Upgrades are
  40. ** free, silly... see below.)
  41. **
  42. ** To run under your Textra (Textra 1.15 or later is required),
  43. ** simply enter "TestMarks" into an Arexx string gadget and press
  44. ** return.
  45. **
  46. ** Registration/Upgrade information...
  47. **
  48. ** Textra 1.17 is under development and will offer significant
  49. ** feature enhancements... I am in the middle of adding auto-
  50. ** word-wrap with ProWrite/MS Word-style sliders.  In the process
  51. ** several bugs have been corrected and other enhancements have
  52. ** been made.  These are available to registered users for the
  53. ** asking (I've always sent upgrades free if you send a SASE-floppy-
  54. ** mailer and floppy, otherwise send $5 if you want me to provide
  55. ** everything.  New registerees ($25) always get the latest &
  56. ** greatest, the same version I use. (Checks drawn on U.S. Banks
  57. ** or U.S. money orders only, please.  Don't send cash!).
  58. **
  59. ** To order a new Textra or upgrade, send the right stuff to:
  60. **
  61. ** Mike Haas
  62. ** 3867 La Colina Rd.
  63. ** El Sobrante, CA 94803
  64. **
  65. ** For more info:  mikeh@starnine.com
  66. **
  67. ** Thanks.
  68. **
  69. */
  70.  
  71. options results
  72.  
  73. rex = 0; result = "NOTSUPPORTED"
  74. textraversion
  75. parse var result maj min rex
  76. if (result == "NOTSUPPORTED") | (rex < 10) then do
  77.     notify "Textra V1.15 or later required for this script."
  78.     exit
  79. end
  80.  
  81. prefs autoindent read;ai = result
  82. prefs autoindent off
  83.  
  84. ask "Display only those tests which reveal problems?"
  85. PrintOnlyBad = result
  86.  
  87. openfile 'ram:Textra Log Window';parse var result logw
  88. if logw = 0 then do
  89.     notify "Error opening 'Textra Log Window'"
  90.     BeGone()
  91. end
  92. clear
  93.  
  94. openfile '"ram:test window"';parse var result tstw
  95. if tstw = 0 then do
  96.     closewindow logw
  97.     notify "Error opening 'test window'"
  98.     BeGone()
  99. end
  100. clear
  101. placewindow "-1" 210 "-1" "-1"
  102.  
  103. testN = 1
  104.  
  105. selectwindow logw
  106. newline
  107. textn '"********************************************************"'
  108. textn '"             Textra MARKS Facility Test 1.0"'
  109. textn '"             ------------------------------"'
  110. textn '"                  Testing version 'maj'.'min'"'
  111. textn '"========================================================"'
  112.  
  113. nErrors = 0
  114.  
  115. /* --------------- TEST 1 --------------- */
  116. str1 = 'Single line mark, cursor on same line, before mark,'
  117. str2 = 'then delete single character'
  118. Call InitTstW
  119. gotoxy 10 2
  120. selectto 20 2
  121. markselect "%%TESTMARK"
  122. gotoxy 5 2
  123. del
  124. gotomark "%%TESTMARK"
  125. if (result ~= OK) then do
  126.     Call ReportResults(1, "Mark was incorrectly deleted")
  127. end
  128. else do
  129.     get select position;parse var result sx' 'sy' 'ex' 'ey
  130.     if ((sx ~= 9) | (sy ~= 2) | (ex ~= 19) | (ey ~= 2)) then do
  131.         Call ReportResults(1,Coords(sx,sy,ex,ey."9 2 19 2"))
  132.     end
  133.     else
  134.         Call ReportResults(0)
  135. end
  136. testn = testn + 1
  137.  
  138. /* --------------- TEST 2 --------------- */
  139. str1 = "Single line mark, cursor within mark, then"
  140. str2 = "delete single character"
  141. Call InitTstW
  142. gotoxy 10 2
  143. selectto 20 2
  144. markselect "%%TESTMARK"
  145. gotoxy 15 2
  146. del
  147. gotomark "%%TESTMARK"
  148. if (result ~= OK) then do
  149.     Call ReportResults(1, "Mark was incorrectly deleted")
  150. end
  151. else do
  152.     get select position;parse var result sx' 'sy' 'ex' 'ey
  153.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 19) | (ey ~= 2)) then do
  154.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 19 2"))
  155.     end
  156.     else
  157.         Call ReportResults(0)
  158. end
  159. testn = testn + 1
  160.  
  161. /* --------------- TEST 3 --------------- */
  162. str1 = "Single line mark, cursor after mark, then"
  163. str2 = "delete single character"
  164. Call InitTstW
  165. gotoxy 10 2
  166. selectto 20 2
  167. markselect "%%TESTMARK"
  168. gotoxy 22 2
  169. del
  170. gotomark "%%TESTMARK"
  171. if (result ~= OK) then do
  172.     Call ReportResults(1, "Mark was incorrectly deleted")
  173. end
  174. else do
  175.     get select position;parse var result sx' 'sy' 'ex' 'ey
  176.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 2)) then do
  177.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 2"))
  178.     end
  179.     else
  180.         Call ReportResults(0)
  181. end
  182. testn = testn + 1
  183.  
  184. /* --------------- TEST 4 --------------- */
  185. str1 = "Single line mark, cursor on previous line, then"
  186. str2 = "delete single character"
  187. Call InitTstW
  188. gotoxy 10 2
  189. selectto 20 2
  190. markselect "%%TESTMARK"
  191. gotoxy 10 1
  192. del
  193. gotomark "%%TESTMARK"
  194. if (result ~= OK) then do
  195.     Call ReportResults(1, "Mark was incorrectly deleted")
  196. end
  197. else do
  198.     get select position;parse var result sx' 'sy' 'ex' 'ey
  199.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 2)) then do
  200.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 2"))
  201.     end
  202.     else
  203.         Call ReportResults(0)
  204. end
  205. testn = testn + 1
  206.  
  207. /* --------------- TEST 5 --------------- */
  208. str1 = "Single line mark, cursor on following line, then"
  209. str2 = "delete single character"
  210. Call InitTstW
  211. gotoxy 10 2
  212. selectto 20 2
  213. markselect "%%TESTMARK"
  214. gotoxy 10 3
  215. del
  216. gotomark "%%TESTMARK"
  217. if (result ~= OK) then do
  218.     Call ReportResults(1, "Mark was incorrectly deleted")
  219. end
  220. else do
  221.     get select position;parse var result sx' 'sy' 'ex' 'ey
  222.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 2)) then do
  223.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 2"))
  224.     end
  225.     else
  226.         Call ReportResults(0)
  227. end
  228. testn = testn + 1
  229.  
  230. /* --------------- TEST 6 --------------- */
  231. str1 = "Single line mark, cursor on same line and before,"
  232. str2 = "then newline"
  233. Call InitTstW
  234. gotoxy 10 2
  235. selectto 20 2
  236. markselect "%%TESTMARK"
  237. gotoxy 5 2
  238. newline
  239. gotomark "%%TESTMARK"
  240. if (result ~= OK) then do
  241.     Call ReportResults(1, "Mark was incorrectly deleted")
  242. end
  243. else do
  244.     get select position;parse var result sx' 'sy' 'ex' 'ey
  245.     if ((sx ~= 5) | (sy ~= 3) | (ex ~= 15) | (ey ~= 3)) then do
  246.         Call ReportResults(1,Coords(sx,sy,ex,ey,"5 3 15 3"))
  247.     end
  248.     else
  249.         Call ReportResults(0)
  250. end
  251. testn = testn + 1
  252.  
  253. /* --------------- TEST 7 --------------- */
  254. str1 = "Single line mark, cursor within mark, then newline"
  255. str2 = ""
  256. Call InitTstW
  257. gotoxy 10 2
  258. selectto 20 2
  259. markselect "%%TESTMARK"
  260. gotoxy 15 2
  261. newline
  262. gotomark "%%TESTMARK"
  263. if (result ~= OK) then do
  264.     Call ReportResults(1, "Mark was incorrectly deleted")
  265. end
  266. else do
  267.     get select position;parse var result sx' 'sy' 'ex' 'ey
  268.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 5) | (ey ~= 3)) then do
  269.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 5 3"))
  270.     end
  271.     else
  272.         Call ReportResults(0)
  273. end
  274. testn = testn + 1
  275.  
  276. /* --------------- TEST 8 --------------- */
  277. str1 = "Single line mark, cursor after mark, then newline"
  278. str2 = ""
  279. Call InitTstW
  280. gotoxy 10 2
  281. selectto 20 2
  282. markselect "%%TESTMARK"
  283. gotoxy 22 2
  284. newline
  285. gotomark "%%TESTMARK"
  286. if (result ~= OK) then do
  287.     Call ReportResults(1, "Mark was incorrectly deleted")
  288. end
  289. else do
  290.     get select position;parse var result sx' 'sy' 'ex' 'ey
  291.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 2)) then do
  292.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 2"))
  293.     end
  294.     else
  295.         Call ReportResults(0)
  296. end
  297. testn = testn + 1
  298.  
  299. /* --------------- TEST 9 --------------- */
  300. str1 = "Single line mark, cursor on previous line, then"
  301. str2 = "newline"
  302. Call InitTstW
  303. gotoxy 10 2
  304. selectto 20 2
  305. markselect "%%TESTMARK"
  306. gotoxy 10 1
  307. newline
  308. gotomark "%%TESTMARK"
  309. if (result ~= OK) then do
  310.     Call ReportResults(1, "Mark was incorrectly deleted")
  311. end
  312. else do
  313.     get select position;parse var result sx' 'sy' 'ex' 'ey
  314.     if ((sx ~= 10) | (sy ~= 3) | (ex ~= 20) | (ey ~= 3)) then do
  315.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 3 20 3"))
  316.     end
  317.     else
  318.         Call ReportResults(0)
  319. end
  320. testn = testn + 1
  321.  
  322. /* --------------- TEST 10 --------------- */
  323. str1 = "Single line mark, cursor on following line, then"
  324. str2 = "newline"
  325. Call InitTstW
  326. gotoxy 10 2
  327. selectto 20 2
  328. markselect "%%TESTMARK"
  329. gotoxy 10 3
  330. newline
  331. gotomark "%%TESTMARK"
  332. if (result ~= OK) then do
  333.     Call ReportResults(1, "Mark was incorrectly deleted")
  334. end
  335. else do
  336.     get select position;parse var result sx' 'sy' 'ex' 'ey
  337.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 2)) then do
  338.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 2"))
  339.     end
  340.     else
  341.         Call ReportResults(0)
  342. end
  343. testn = testn + 1
  344.  
  345. /* --------------- TEST 11 --------------- */
  346. str1 = "Two-line mark, cursor on start line, before mark,"
  347. str2 = "then delete single character"
  348. Call InitTstW
  349. gotoxy 10 1
  350. selectto 20 2
  351. markselect "%%TESTMARK"
  352. gotoxy 5 1
  353. del
  354. gotomark "%%TESTMARK"
  355. if (result ~= OK) then do
  356.     Call ReportResults(1, "Mark was incorrectly deleted")
  357. end
  358. else do
  359.     get select position;parse var result sx' 'sy' 'ex' 'ey
  360.     if ((sx ~= 9) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  361.         Call ReportResults(1,Coords(sx,sy,ex,ey,"9 1 20 2"))
  362.     end
  363.     else
  364.         Call ReportResults(0)
  365. end
  366. testn = testn + 1
  367.  
  368. /* --------------- TEST 12 --------------- */
  369. str1 = "Two-line mark, cursor within mark, then"
  370. str2 = "delete single character"
  371. Call InitTstW
  372. gotoxy 10 1
  373. selectto 20 2
  374. markselect "%%TESTMARK"
  375. gotoxy 15 2
  376. del
  377. gotomark "%%TESTMARK"
  378. if (result ~= OK) then do
  379.     Call ReportResults(1, "Mark was incorrectly deleted")
  380. end
  381. else do
  382.     get select position;parse var result sx' 'sy' 'ex' 'ey
  383.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 19) | (ey ~= 2)) then do
  384.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 19 2"))
  385.     end
  386.     else
  387.         Call ReportResults(0)
  388. end
  389. testn = testn + 1
  390.  
  391. /* --------------- TEST 13 --------------- */
  392. str1 = "Two-line mark, cursor after mark, then"
  393. str2 = "delete single character"
  394. Call InitTstW
  395. gotoxy 10 1
  396. selectto 20 2
  397. markselect "%%TESTMARK"
  398. gotoxy 22 2
  399. del
  400. gotomark "%%TESTMARK"
  401. if (result ~= OK) then do
  402.     Call ReportResults(1, "Mark was incorrectly deleted")
  403. end
  404. else do
  405.     get select position;parse var result sx' 'sy' 'ex' 'ey
  406.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  407.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 2"))
  408.     end
  409.     else
  410.         Call ReportResults(0)
  411. end
  412. testn = testn + 1
  413.  
  414. /* --------------- TEST 14 --------------- */
  415. testn = testn + 1
  416. str1 = "Two-line mark, cursor on previous line, then"
  417. str2 = "delete single character"
  418. Call InitTstW
  419. gotoxy 10 1
  420. selectto 20 2
  421. markselect "%%TESTMARK"
  422. gotoxy 10 0
  423. del
  424. gotomark "%%TESTMARK"
  425. if (result ~= OK) then do
  426.     Call ReportResults(1, "Mark was incorrectly deleted")
  427. end
  428. else do
  429.     get select position;parse var result sx' 'sy' 'ex' 'ey
  430.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  431.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 2"))
  432.     end
  433.     else
  434.         Call ReportResults(0)
  435. end
  436. testn = testn + 1
  437.  
  438. /* --------------- TEST 15 --------------- */
  439. str1 = "Two-line mark, cursor on following line, then"
  440. str2 = "delete single character"
  441. Call InitTstW
  442. gotoxy 10 1
  443. selectto 20 2
  444. markselect "%%TESTMARK"
  445. gotoxy 10 3
  446. del
  447. gotomark "%%TESTMARK"
  448. if (result ~= OK) then do
  449.     Call ReportResults(1, "Mark was incorrectly deleted")
  450. end
  451. else do
  452.     get select position;parse var result sx' 'sy' 'ex' 'ey
  453.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  454.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 2"))
  455.     end
  456.     else
  457.         Call ReportResults(0)
  458. end
  459. testn = testn + 1
  460.  
  461. /* --------------- TEST 16 --------------- */
  462. str1 = "Two-line mark, cursor on 1st line and before,"
  463. str2 = "then newline"
  464. Call InitTstW
  465. gotoxy 10 1
  466. selectto 20 2
  467. markselect "%%TESTMARK"
  468. gotoxy 5 1
  469. newline
  470. gotomark "%%TESTMARK"
  471. if (result ~= OK) then do
  472.     Call ReportResults(1, "Mark was incorrectly deleted")
  473. end
  474. else do
  475.     get select position;parse var result sx' 'sy' 'ex' 'ey
  476.     if ((sx ~= 5) | (sy ~= 2) | (ex ~= 20) | (ey ~= 3)) then do
  477.         Call ReportResults(1,Coords(sx,sy,ex,ey,"5 2 20 3"))
  478.     end
  479.     else
  480.         Call ReportResults(0)
  481. end
  482. testn = testn + 1
  483.  
  484. /* --------------- TEST 17 --------------- */
  485. str1 = "Two-line mark, cursor within mark, then newline"
  486. str2 = ""
  487. Call InitTstW
  488. gotoxy 10 1
  489. selectto 20 2
  490. markselect "%%TESTMARK"
  491. gotoxy 15 2
  492. newline
  493. gotomark "%%TESTMARK"
  494. if (result ~= OK) then do
  495.     Call ReportResults(1, "Mark was incorrectly deleted")
  496. end
  497. else do
  498.     get select position;parse var result sx' 'sy' 'ex' 'ey
  499.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 5) | (ey ~= 3)) then do
  500.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 5 3"))
  501.     end
  502.     else
  503.         Call ReportResults(0)
  504. end
  505. testn = testn + 1
  506.  
  507. /* --------------- TEST 18 --------------- */
  508. str1 = "Two-line mark, cursor after mark, then newline"
  509. str2 = ""
  510. Call InitTstW
  511. gotoxy 10 1
  512. selectto 20 2
  513. markselect "%%TESTMARK"
  514. gotoxy 22 2
  515. newline
  516. gotomark "%%TESTMARK"
  517. if (result ~= OK) then do
  518.     Call ReportResults(1, "Mark was incorrectly deleted")
  519. end
  520. else do
  521.     get select position;parse var result sx' 'sy' 'ex' 'ey
  522.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  523.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 2"))
  524.     end
  525.     else
  526.         Call ReportResults(0)
  527. end
  528. testn = testn + 1
  529.  
  530. /* --------------- TEST 19 --------------- */
  531. str1 = "Two-line mark, cursor on previous line, then"
  532. str2 = "newline"
  533. Call InitTstW
  534. gotoxy 10 1
  535. selectto 20 2
  536. markselect "%%TESTMARK"
  537. gotoxy 10 0
  538. newline
  539. gotomark "%%TESTMARK"
  540. if (result ~= OK) then do
  541.     Call ReportResults(1, "Mark was incorrectly deleted")
  542. end
  543. else do
  544.     get select position;parse var result sx' 'sy' 'ex' 'ey
  545.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 3)) then do
  546.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 3"))
  547.     end
  548.     else
  549.         Call ReportResults(0)
  550. end
  551. testn = testn + 1
  552.  
  553. /* --------------- TEST 20 --------------- */
  554. str1 = "Two-line mark, cursor on following line, then"
  555. str2 = "newline"
  556. Call InitTstW
  557. gotoxy 10 1
  558. selectto 20 2
  559. markselect "%%TESTMARK"
  560. gotoxy 10 3
  561. newline
  562. gotomark "%%TESTMARK"
  563. if (result ~= OK) then do
  564.     Call ReportResults(1, "Mark was incorrectly deleted")
  565. end
  566. else do
  567.     get select position;parse var result sx' 'sy' 'ex' 'ey
  568.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 2)) then do
  569.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 2"))
  570.     end
  571.     else
  572.         Call ReportResults(0)
  573. end
  574. testn = testn + 1
  575.  
  576. /* --------------- TEST 21 --------------- */
  577. str1 = "Multi-line mark, cursor on start line, before mark,"
  578. str2 = "then delete single character"
  579. Call InitTstW
  580. gotoxy 10 1
  581. selectto 20 3
  582. markselect "%%TESTMARK"
  583. gotoxy 5 1
  584. del
  585. gotomark "%%TESTMARK"
  586. if (result ~= OK) then do
  587.     Call ReportResults(1, "Mark was incorrectly deleted")
  588. end
  589. else do
  590.     get select position;parse var result sx' 'sy' 'ex' 'ey
  591.     if ((sx ~= 9) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  592.         Call ReportResults(1,Coords(sx,sy,ex,ey,"9 1 20 3"))
  593.     end
  594.     else
  595.         Call ReportResults(0)
  596. end
  597. testn = testn + 1
  598.  
  599. /* --------------- TEST 22 --------------- */
  600. str1 = "Multi-line mark, cursor within mark, then"
  601. str2 = "delete single character"
  602. Call InitTstW
  603. gotoxy 10 1
  604. selectto 20 3
  605. markselect "%%TESTMARK"
  606. gotoxy 15 2
  607. del
  608. gotomark "%%TESTMARK"
  609. if (result ~= OK) then do
  610.     Call ReportResults(1, "Mark was incorrectly deleted")
  611. end
  612. else do
  613.     get select position;parse var result sx' 'sy' 'ex' 'ey
  614.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  615.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  616.     end
  617.     else
  618.         Call ReportResults(0)
  619. end
  620. testn = testn + 1
  621.  
  622. /* --------------- TEST 23 --------------- */
  623. str1 = "Multi-line mark, cursor after mark, then"
  624. str2 = "delete single character"
  625. Call InitTstW
  626. gotoxy 10 1
  627. selectto 20 3
  628. markselect "%%TESTMARK"
  629. gotoxy 22 3
  630. del
  631. gotomark "%%TESTMARK"
  632. if (result ~= OK) then do
  633.     Call ReportResults(1, "Mark was incorrectly deleted")
  634. end
  635. else do
  636.     get select position;parse var result sx' 'sy' 'ex' 'ey
  637.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  638.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  639.     end
  640.     else
  641.         Call ReportResults(0)
  642. end
  643.  
  644. /* --------------- TEST 24 --------------- */
  645. testn = testn + 1
  646. str1 = "Multi-line mark, cursor on previous line, then"
  647. str2 = "delete single character"
  648. Call InitTstW
  649. gotoxy 10 1
  650. selectto 20 3
  651. markselect "%%TESTMARK"
  652. gotoxy 10 0
  653. del
  654. gotomark "%%TESTMARK"
  655. if (result ~= OK) then do
  656.     Call ReportResults(1, "Mark was incorrectly deleted")
  657. end
  658. else do
  659.     get select position;parse var result sx' 'sy' 'ex' 'ey
  660.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  661.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  662.     end
  663.     else
  664.         Call ReportResults(0)
  665. end
  666. testn = testn + 1
  667.  
  668. /* --------------- TEST 25 --------------- */
  669. str1 = "Multi-line mark, cursor on following line, then"
  670. str2 = "delete single character"
  671. Call InitTstW
  672. gotoxy 10 1
  673. selectto 20 3
  674. markselect "%%TESTMARK"
  675. gotoxy 10 4
  676. del
  677. gotomark "%%TESTMARK"
  678. if (result ~= OK) then do
  679.     Call ReportResults(1, "Mark was incorrectly deleted")
  680. end
  681. else do
  682.     get select position;parse var result sx' 'sy' 'ex' 'ey
  683.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  684.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  685.     end
  686.     else
  687.         Call ReportResults(0)
  688. end
  689. testn = testn + 1
  690.  
  691. /* --------------- TEST 26 --------------- */
  692. str1 = "Multi-line mark, cursor on 1st line and before,"
  693. str2 = "then newline"
  694. Call InitTstW
  695. gotoxy 10 1
  696. selectto 20 3
  697. markselect "%%TESTMARK"
  698. gotoxy 5 1
  699. newline
  700. gotomark "%%TESTMARK"
  701. if (result ~= OK) then do
  702.     Call ReportResults(1, "Mark was incorrectly deleted")
  703. end
  704. else do
  705.     get select position;parse var result sx' 'sy' 'ex' 'ey
  706.     if ((sx ~= 5) | (sy ~= 2) | (ex ~= 20) | (ey ~= 4)) then do
  707.         Call ReportResults(1,Coords(sx,sy,ex,ey,"5 2 20 4"))
  708.     end
  709.     else
  710.         Call ReportResults(0)
  711. end
  712. testn = testn + 1
  713.  
  714. /* --------------- TEST 27 --------------- */
  715. str1 = "Multi-line mark, cursor within mark, then newline"
  716. str2 = ""
  717. Call InitTstW
  718. gotoxy 10 1
  719. selectto 20 3
  720. markselect "%%TESTMARK"
  721. gotoxy 15 2
  722. newline
  723. gotomark "%%TESTMARK"
  724. if (result ~= OK) then do
  725.     Call ReportResults(1, "Mark was incorrectly deleted")
  726. end
  727. else do
  728.     get select position;parse var result sx' 'sy' 'ex' 'ey
  729.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 4)) then do
  730.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 4"))
  731.     end
  732.     else
  733.         Call ReportResults(0)
  734. end
  735. testn = testn + 1
  736.  
  737. /* --------------- TEST 28 --------------- */
  738. str1 = "Multi-line mark, cursor after mark, then newline"
  739. str2 = ""
  740. Call InitTstW
  741. gotoxy 10 1
  742. selectto 20 3
  743. markselect "%%TESTMARK"
  744. gotoxy 22 3
  745. newline
  746. gotomark "%%TESTMARK"
  747. if (result ~= OK) then do
  748.     Call ReportResults(1, "Mark was incorrectly deleted")
  749. end
  750. else do
  751.     get select position;parse var result sx' 'sy' 'ex' 'ey
  752.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  753.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  754.     end
  755.     else
  756.         Call ReportResults(0)
  757. end
  758. testn = testn + 1
  759.  
  760. /* --------------- TEST 29 --------------- */
  761. str1 = "Multi-line mark, cursor on previous line, then"
  762. str2 = "newline"
  763. Call InitTstW
  764. gotoxy 10 1
  765. selectto 20 3
  766. markselect "%%TESTMARK"
  767. gotoxy 10 0
  768. newline
  769. gotomark "%%TESTMARK"
  770. if (result ~= OK) then do
  771.     Call ReportResults(1, "Mark was incorrectly deleted")
  772. end
  773. else do
  774.     get select position;parse var result sx' 'sy' 'ex' 'ey
  775.     if ((sx ~= 10) | (sy ~= 2) | (ex ~= 20) | (ey ~= 4)) then do
  776.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 2 20 4"))
  777.     end
  778.     else
  779.         Call ReportResults(0)
  780. end
  781. testn = testn + 1
  782.  
  783. /* --------------- TEST 30 --------------- */
  784. str1 = "Multi-line mark, cursor on following line, then"
  785. str2 = "newline"
  786. Call InitTstW
  787. gotoxy 10 1
  788. selectto 20 3
  789. markselect "%%TESTMARK"
  790. gotoxy 10 4
  791. newline
  792. gotomark "%%TESTMARK"
  793. if (result ~= OK) then do
  794.     Call ReportResults(1, "Mark was incorrectly deleted")
  795. end
  796. else do
  797.     get select position;parse var result sx' 'sy' 'ex' 'ey
  798.     if ((sx ~= 10) | (sy ~= 1) | (ex ~= 20) | (ey ~= 3)) then do
  799.         Call ReportResults(1,Coords(sx,sy,ex,ey,"10 1 20 3"))
  800.     end
  801.     else
  802.         Call ReportResults(0)
  803. end
  804. testn = testn + 1
  805.  
  806. /* --------------- ALL DONE --------------- */
  807. selectwindow tstw
  808. closewindow
  809. selectwindow logw
  810. newline
  811. if (nErrors = 0) then
  812.     textn "No problems occurred."
  813. else do
  814.     textn nErrors" problems occurred.  This Textra should be upgraded..."
  815.     textn "the latest Textra runs this test with no failures.  See this"
  816.     textn "script's comment for ordering/free upgrade information."
  817. end
  818. BeGone()
  819. exit        /* let's just make sure! :-) */
  820.  
  821. BeGone:
  822.     prefs autoindent ai
  823.     exit
  824. return 0
  825.  
  826. /* ---------------- subroutines ---------------- */
  827.  
  828. InitTstW:
  829.     Call ShouldIDie()
  830.     selectwindow tstw
  831.     statustext '"Test 'testn'"'
  832.     clear
  833.     deletemark "%%TESTMARK"
  834.     textn "0123456789 123456789 123456789 123456789"
  835.     textn "123456789 123456789 123456789 123456789 "
  836.     textn "23456789 123456789 123456789 123456789 1"
  837.     textn "3456789 123456789 123456789 123456789 23"
  838.     textn "456789 123456789 123456789 123456789 234"
  839. return
  840.  
  841. ReportResults:
  842.     parse arg testres,resstr
  843.     if (str1 ~= "") then do
  844.         selectwindow tstw
  845.         if (testres = 0) then
  846.             statustext '"Test 'testn' worked fine"'
  847.         else do
  848.             statustext '"Test 'testn' had a problem"'
  849.             nErrors = nErrors + 1
  850.         end
  851.     end
  852.     if ((PrintOnlyBad == "NO") | ((PrintOnlyBad == "YES") & (testres ~= 0))) then do
  853.         selectwindow logw
  854.         if (str1 ~= "") then
  855.             Call Announce(testres)
  856.         if (testres = 0) then
  857.             textn "TEST OK"
  858.         else
  859.             textn "PROBLEM: "resstr
  860.     end
  861. return 0
  862.  
  863. Coords:
  864.     parse arg na,nb,nc,nd,exp
  865.     str = "Mark position = "
  866.     str = overlay(na,str,length(str)+1)
  867.     str = overlay(" ",str,length(str)+1)
  868.     str = overlay(nb,str,length(str)+1)
  869.     str = overlay(" ",str,length(str)+1)
  870.     str = overlay(nc,str,length(str)+1)
  871.     str = overlay(" ",str,length(str)+1)
  872.     str = overlay(nd,str,length(str)+1)
  873.     if (exp ~= "") then do
  874.         str = overlay("  Expected = ",str,length(str)+1)
  875.         str = overlay(exp,str,length(str)+1)
  876.     end
  877. return str
  878.  
  879. Announce:
  880.     parse arg res
  881.     if ((PrintOnlyBad == "NO") | ((PrintOnlyBad == "YES") & (res ~= 0))) then do
  882.         selectwindow logw
  883.         newline
  884.         textn '"TEST 'testn' ---------------------------------------------"'
  885.         textn '"      'str1'"'
  886.         str1 = ""
  887.         if (str2 ~= "") then
  888.             textn '"      'str2'"'
  889.     do
  890. return
  891.  
  892. ShouldIDie:
  893.     CheckCancel; if (result == CANCEL) then do
  894.         selectwindow tstw
  895.         closewindow
  896.         selectwindow logw
  897.         newline
  898.         textn "Test Canceled"
  899.         BeGone()
  900.     end
  901. return
  902.